class AddNovelParentReference < ActiveRecord::Migration
  def self.up
	add_column :novels, :parent_id, :integer #self join acts_as_tree
	rename_column :novels, :fragment_number, :folk_from_chapter
	remove_column :fragments, :novel_id
	rename_column :fragments, :fragment_number, :chapter_id #foreign key for chapter
	rename_column :merge_histories, :fragment_number, :chapter_id 

  end

  def self.down
    remove_column :novels, :parent_id
	rename_column :novels, :folk_from_chapter, :fragment_number
	add_column :fragments, :novel_id, :integer
	rename_column :fragments, :chapter_id, :fragment_number
	rename_column :merge_histories, :chapter_id,  :fragment_number
  end
end
